'''
Created on 2019年9月2日

@author: bkd
'''
import time
import requests
if __name__ == '__main__':
    
    url = 'https://login.weixin.qq.com/jslogin'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36',
    }
    now = str(int(time.time()))
    r = requests.post(url,headers=headers,params = {"appid":'wx782c26e4c19acffb',"fun":"new","lang":"zh_CN","_":now})
    print(r.text)
    uuid = r.text.split(";")[1].split('= "')[1][:-1]
    print("uuid:"+uuid)
#     get_qrcocde_url ='https://login.weixin.qq.com/l/' + str(uuid)
    get_qrcocde_url ='https://login.weixin.qq.com/qrcode/' + uuid
#     now = str(int(time.time()))
#     r = requests.get(get_qrcocde_url,headers=headers,params={"tip":0,"uuid":uuid,"_":now})
    r = requests.get(get_qrcocde_url,headers=headers)
#     print(r.text)
    with open("/tmp/q","wb") as f:
        f.write(r.content)